function loadFriends() {

  var req = opensocial.newDataRequest();
  var params = {};
  params[opensocial.DataRequest.PeopleRequestFields.MAX] = 100;
  req.add(req.newFetchPersonRequest('VIEWER'), 'viewer');
  req.add(req.newFetchPeopleRequest(opensocial.DataRequest.Group.OWNER_FRIENDS, params), "ownerFriends");
  req.send(onLoadFriends);
}

function onLoadFriends(data) {
  var viewer = data.get('viewer').getData();
  var viewerFriends = data.get('ownerFriends').getData();
  
  html = new Array();

alert(viewerFriends.toString()+", "+ viewerFriends.toSource());
alert(viewerFriends.prototype);
alert(viewerFriends.constructor.toString());


  html.push('Totalnumber of friends : '+"   "+viewerFriends.size());
  html.push('<ul>');
  viewerFriends.each(function(person) {
    html.push('<li>' + person.getDisplayName() + "</li>");
  });
  html.push('</ul>');
  document.getElementById('friends').innerHTML = html.join('');
}

function init() {
  loadFriends();
}